package com.chaos.controller;/*
 * Date: 2023/10/13 7:58 AM
 * Function():
 * Author: Chao
 */

import com.chaos.domain.Cartoon;
import com.chaos.response.ResponseResult;
import com.chaos.service.CartoonService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/cartoon")
@CrossOrigin
@Api(tags = "海尔兄弟剧情")
public class CartoonController {
    @Autowired
    private CartoonService cartoonService;

    @RequestMapping(value = "/selectByPrimaryKey",method = RequestMethod.GET)
    public ResponseResult selectByPrimaryKey() {
        ResponseResult re = new ResponseResult();
        re.setCode(200);
        re.setObject(cartoonService.selectByPrimaryKey(1).toString());
        re.setMessage("Success");
        return re;
    }

    @RequestMapping(value = "/selectAll",method = RequestMethod.GET)
    public ResponseResult selectAll() {
        ResponseResult re = new ResponseResult();
        re.setCode(200);
        re.setObject(cartoonService.selectAll());
        re.setMessage("Success");
        return re;
    }

    @ApiOperation("更新")
    @RequestMapping(value = "/updateByPrimarykey",method = RequestMethod.POST)
//    @ApiImplicitParams(
//            @ApiImplicitParam(name = "cartoon", value = "test", paramType = "body", required = true, dataType = "Cartoon")
//    )
    public ResponseResult updateByPrimarykey(@RequestBody Cartoon cartoon) {
        ResponseResult re = new ResponseResult();
        re.setCode(200);
        re.setObject(cartoonService.updateByPrimaryKey(cartoon));
        re.setMessage("Success");
        return re;
    }
}
